-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ember.A should not modify underlying array #20245
base: main
Are you sure you want to change the base?
Conversation
|
||
const emberArrayLastObject = nonEnumerableComputed(function () { | ||
return objectAt(this, this.length - 1); | ||
}).readOnly(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love how we're assigning them to variables here, but I can't find any other good way to get a reference to their CPs.
let proxy = new Proxy(arr, { | ||
get(target, prop /*, _receiver */) { | ||
// These nonEnumerableComputed properties need special handling | ||
if (prop === '[]') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we'd have something more generic, but we aren't going to be adding stuff to EmberArray going forwards so this should be fine.
@wagenet note that "Extend Prototypes" is failing on CI. |
7dd16a6
to
7aa79fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable to me, but I'd still really like it if someone who's more familiar with this could give it some 👀 as well. @rwjblue do you have 10 minutes (tops) to look at it?
I think I'd like to put this behind a flag. I think (hope) it won't cause issues for people, but who knows what people are actually doing and whether they're relying on the mutating behavior. |
7aa79fa
to
0b2ab6f
Compare
00ccece
to
582831f
Compare
I agree that it should go behind a flag. Because many addons call |
582831f
to
331a4a6
Compare
@wagenet I'm working on pushing |
@locks This was partially motivated by issues Ember Data was having. @runspired what's the status of that stuff? |
still needed. iirc the solution for most has been to turn prototype extensions back on |
Is this still relevant? |
@kategengler I believe so |
@wagenet should we merge then? |
@kategengler I would like to and it is flagged so it should be safe. That said, I haven't really gotten a proper review from anyone still. |
I don't have a clue here or I would offer you one :) I'm just triaging PRs. |
can this be rebasod? |
331a4a6
to
dd75266
Compare
// SAFETY: This will return an NativeArray but TS can't infer that. | ||
return NativeArray.apply(arr ?? []) as NativeArray<T>; | ||
if (EMBER_A_NON_MODIFYING) { | ||
// Remove this in Ember 5.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5.0? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh... should be 6.0 now, I guess.
Resolves #20219